package com.blackcat.recode.controller;


import com.blackcat.recode.common.annotation.Log;
import com.blackcat.recode.common.result.AjaxResult;
import com.blackcat.recode.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.blackcat.recode.service.CustomerService;
import com.blackcat.recode.entity.Customer;

/**
 * <p> 客户信息表 前端控制器
 * @author blackcat 2024-09-10
 */
@RestController
@RequestMapping("/customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @GetMapping("/getAllCustomerList")
    public AjaxResult getAllCustomerList() {
        return customerService.getAllCustomerList();
    }

    @GetMapping("/getList")
    public AjaxResult getList(Integer page, Integer size, String customerName) {
        return customerService.getList(page,size,customerName);
    }

    @Log(title = "项目编辑", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody Customer customer) {
        return customerService.edit(customer);
    }

    @GetMapping("/getOne")
    public AjaxResult getOne(String id) {
        return AjaxResult.success(customerService.getById(id));
    }

    @Log(title = "项目删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(String id) {
        customerService.removeById(id);
        return AjaxResult.success();
    }

    @GetMapping("/getCustomerNameList")
    public AjaxResult getCustomerNameList() {
        return customerService.getCustomerNameList();
    }
}
